<template>
  <div>
    <div style="width: 100%">
      <el-input placeholder="输入姓名"  style="width: 250px" v-model="uname" />
      <el-input placeholder="输入电话"  style="width: 250px" v-model="phone" />
      <el-select v-model="rid" placeholder="选择角色" >
        <el-option
          v-for="item in role"
          :key="item.rid"
          :value="item.rid"
          :label="item.rname"
        />
      </el-select>
      
      <el-button @click="getAllWorker" type="primary" icon="el-icon-search"
        >查询</el-button
      >
    </div>
  
    <br /><br />
    <el-table
      ref="multipleTable"
      :data="pageInfo.list"
      tooltip-effect="dark"
      style="width: 80%; margin: 0px auto"
    >
      <el-table-column
        prop="tbUser.phone"
        label="电话号码"
         width="200"
      ></el-table-column>
      <el-table-column
        prop="uname"
        label=" 姓名"
         width="200"
      ></el-table-column>
      <el-table-column
        prop="idCard"
        label="银行卡号"
         width="200"
      ></el-table-column>
      <el-table-column
        prop="gender"
        label="性别"
        width="200"
      ></el-table-column>
      <el-table-column
        prop="birthday"
        label="生日"
        width="200"
      ></el-table-column>
      <el-table-column
        prop="tbRole.rname"
        label="职位"
        width="200"
      ></el-table-column>
      <el-table-column
        prop="salary"
        label="工资"
        width="200"
      ></el-table-column>
     
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageInfo.pageNum"
      :page-sizes="[3, 5, 8, 10]"
      :page-size="pageInfo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total"
    >
    </el-pagination>
  
  </div>
</template>
<style>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>
<script>
import { getAllworker,getallrole } from "@/api/Salary.js";

export default {
  data() {
    return {
      pageInfo: {
        pageNum: 1,
        pageSize: 10,
      },
      phone: "",
      uname: "",
      rid: "",
      role: [],
    };
  },
  methods: {

    getAllWorker() {
      getAllworker({
        pageNum: this.pageInfo.pageNum,
        pageSize: this.pageInfo.pageSize,
        phone: this.phone,
        uname: this.uname,
        rid: this.rid,
      }).then((res) => {
        if (res.data.code == 200) {
          this.pageInfo = res.data.data;
          this.phone = "";
          this.rid = "";
          this.uname = "";
        }
      });
    },
    getRole() {
      getallrole().then((res) => {
        if (res.data.code == 200) {
          this.role = res.data.data;
        }
      });
    },
    //val=改变之后的条目数
    handleSizeChange(val) {
      this.pageInfo.pageSize = val;
      this.pageInfo.pageNum = 1;
      this.getAllWorker();
    },
    //改变之后的当前页
    handleCurrentChange(val) {
      this.pageInfo.pageNum = val;
      this.getAllWorker();
    },
  },
  mounted() {
    this.getAllWorker();
    this.getRole();
  },
};
</script>